<template>
    <div>
      <!-- 表格数据 -->
      <el-table :data="tableData" stripe style="width: 100%">
        <el-table-column prop="code" label="询价编号" align="center" />
        <el-table-column prop="enquiryDate" label="询价时间" align="center" />
        <el-table-column prop="status" label="状态" align="center">
          <template #default="{ row }">
            <span v-if="row.status == 1">待报价</span>
            <span v-else-if="row.status == 2">报价中</span>
            <span v-else-if="row.status == 3">已报价</span>
          </template>
        </el-table-column>
        <el-table-column prop="" label="修改描述" align="center" />
        <el-table-column prop="reason" label="原因" align="center" />
        <el-table-column label="操作" align="center" width="420px">
          <template #default="{ row }">
            <el-button @click="toOffer(row.id)">报价</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div style="background-color: #fff">
        <el-pagination
          layout="prev, pager, next,sizes,total,jumper"
          :total="total"
          @current-change="chpage"
          @size-change="chsize"
        />
      </div>
    </div>
  </template>
  
  <script setup>
  import { ref, onBeforeMount } from "vue";
  import { useRouter } from "vue-router";
  import { query } from "@/api/supplier.js";
  import { getUser } from "@/utils/session.js";
  const router = useRouter(); // 获取路由对象
  const tableData = ref([]);
  let params = ref({
    page: 1,
    pageSize: 10,
    sid: 5
  });
  const total = ref(0); // 总记录数
  
  // 分页查询询价单列表
  async function getList() {
    // 准备查询参数
  
    let res = await query(params.value);
    if (res.code == 200) {
      tableData.value = res.data.list;
      params.value.page = res.data.page;
      params.value.pageSize = res.data.pageSize;
      total.value = res.data.total;
    }
  }
  
  //报价
  function toOffer(id) {
    router.push({ name: "supplieroffer", query: { id } });
  }
  
  // 重置表单
  function reset() {
    data.value.enquiy_id = "";
    data.value.order_id = "";
    getList(); // 重置后重新加载列表
  }
  
  // 分页处理
  function chpage(pg) {
    page.value = pg;
    getList();
  }
  
  function chsize(ps) {
    pageSize.value = ps;
    page.value = 1;
    getList();
  }
  
  // 初始化加载列表
  onBeforeMount(() => {
    getList();
  });
  </script>
  
  <style scoped>
  .basic {
    font-size: 24px;
    font-weight: bold;
    color: #0054a6;
    display: inline-block;
    border-style: none;
  }
  </style>
  